package shujia.day12.ketang;

import java.io.File;
import java.io.FileFilter;
import java.util.Arrays;

/*
    public String[] list(FilenameFilter filter)
    public File[] listFiles(FilenameFilter filter)

 */
public class FileTest2 {
    public static void main(String[] args) {
        File file = new File("E:\\");

        File[] files = file.listFiles(new FileFilter() {
            @Override
            public boolean accept(File pathname) {
                // 这里返回是true还是false需要自己编写代码逻辑
//                return true;
                return pathname.isFile() && pathname.getName().endsWith(".jpg");
            }
        });

//        File[] files = file.listFiles(pathname -> pathname.isFile() && pathname.getName().endsWith(".jpg"));

        System.out.println(Arrays.toString(files));
    }
}
